package com.vcc.core.enumConstant;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
import java.util.stream.Collectors;


@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
public enum RoleEnum {
    ADMIN("1", "ADMIN"),
    DEALER("2", "DEALER"),
    USER("3", "USER");

    private final String value;

    @JsonValue
    private final String code;

    RoleEnum(String value, String code) {
        this.value = value;
        this.code = code;
    }


    public static RoleEnum getByCode(String value) {
        return Arrays.stream(RoleEnum.values()).filter(it -> it.value.equals(value)).toList().get(0);
    }

    public String getValue() {
        return value;
    }

    public String getCode() {
        return code;
    }
}
